package com.lvy.hczn.transmit.controller;

import com.lvy.hczn.front.common.core.domain.AjaxResult;
import com.lvy.hczn.front.common.exception.UtilException;
import com.lvy.hczn.front.system.domain.business.ProductionProcessingType;
import com.lvy.hczn.mq.rocket.ParamInfo;
import com.lvy.hczn.transmit.service.TProductionProcessingTypeService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @description: 生产加工方式
 * @projectName: wms-front
 * @package: com.lvy.hczn.transmit.controller
 * @className: TProductionProcessingTypeController
 * @author: yw
 * @date: 2024/12/31 14:55
 */
@RequestMapping("/api/dt/processing/")
@RestController
@Slf4j
public class TProductionProcessingTypeController {

    @Autowired
    private TProductionProcessingTypeService productionProcessingTypeService;

    /**
     * 平台推送包装袋规格信息
     *
     * @param request
     * @param info
     */
    @ApiOperation(value = "平台推送生产加工方式信息", notes = "平台推送生产加工方式信息")
    @PostMapping("data")
    public AjaxResult syncProductionProcessingTypeFromPlatForm(HttpServletRequest request, @RequestBody ParamInfo<ProductionProcessingType> info) {
        try {
            productionProcessingTypeService.syncProductionProcessingTypeFromPlatForm(request, info);
            return AjaxResult.success();
        } catch (Exception e) {
            if (e instanceof UtilException) {
                return AjaxResult.error(e.getMessage());
            } else {
                log.error("syncProductionProcessingTypeFromPlatForm同步异常：", e);
                return AjaxResult.error("系统异常");
            }
        }
    }
}
